define(function(require, exports, module) {
	
	var dom = $('<span style="display:none;"></span>').appendTo(document.body)[0];

	$.extend({
		mainDesktopVue:new Vue({el:dom, data:[]}),
		commonModal:function(method, msg, callback, loading) {
			callback = callback || function() {};
			var options = {
				title:$.i18n.prop("info.title"),
				content:msg,
				loading:loading,
				okText:$.i18n.prop("info.ok"),
				zIndex: layer.zIndex + 1000,
				onOk:function() {
					return callback.call(this);
				}
			};
			return this.mainDesktopVue.$Modal[method](options);
		},
		alert:function(msg, callback,loading) {
			return this.commonModal("warning", msg, callback, loading);
		},
		info:function(msg, callback, loading) {
			return this.commonModal("info", msg, callback, loading);
		},
		success:function(msg, callback, loading) {
			return this.commonModal("success", msg, callback, loading);
		},
		error:function(msg, callback, loading) {
			return this.commonModal("error", msg, callback, loading);
		},
		confirm:function(msg, callback, loading) {
			callback = callback || function() {};
			var options = {
				title:$.i18n.prop("info.title"),
				content:msg,
				loading:loading,
				cancelText:$.i18n.prop("info.cancel"),
				okText:$.i18n.prop("info.ok"),
				zIndex: layer.zIndex + 1000,
				onOk:function() {
					return callback.call(this, true);
				},
				onCancel:function() {
					return callback.call(this, false);
				}
			};
			return this.mainDesktopVue.$Modal.confirm(options);
		},
		prompt:function(options) {
			var opts = {
				callback: function(value) {}
			}
			$.extend(opts, options);
			return this.mainDesktopVue.$Modal.confirm({
				title:$.i18n.prop("info.title"),
				loading:opts.loading,
				cancelText:$.i18n.prop("info.cancel"),
				okText:$.i18n.prop("info.ok"),
				zIndex: layer.zIndex + 1000,
                render: function(h) {
                    return h('Input', {
                        props: {
                            value: opts.value,
                            autofocus: true,
                            placeholder: opts.msg
                        },
                        on: {
                            input: function(val) {
                                opts.value = val;
                            }
                        }
                    })
                },
                onOk:function() {
                	opts.callback.call(this, opts.value);
                },
                onCancel:function() {
                	opts.callback.call(this, undefined);
                }
            });
		},
		iviewmsg:function(method, args) {
			var me = this.mainDesktopVue.$Message;
			var result = me[method].apply(me, args);
			$('.ivu-message').css({
				'z-index':layer.zIndex + 1000
			});
			return result;
		},
		msginfo:function() {
			return this.iviewmsg("info", arguments);
		},
		msgsuccess:function() {
			return this.iviewmsg("success", arguments);
		},
		msgwarning:function() {
			return this.iviewmsg("warning", arguments);
		},
		msgerror:function() {
			return this.iviewmsg("error", arguments);
		},
		msgloading:function() {
			return this.iviewmsg("loading", arguments);
		}
	});

});